import request from '@/utils/request'
import qs from 'qs'

export function add(data) {
  return request({
    url: 'stock/add',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'stock/delete',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'stock/update',
    method: 'put',
    data
  })
}

export function init(data) {
  return request({
    url: '/stock/initDepot',
    method: 'post',
    data
  })
}
export function all(params) {
  return request({
    url: '/stock/all',
    method: 'get',
    params
  })
}

export function stockLog(productId, depotId) {
  return request({
    url: '/stockLog/page?productId=' + productId + '&depotId=' + depotId,
    method: 'get',
    params: productId, depotId
  })
}
export function exportLog(params) {
  return request({
    url: 'stockLog/export' + '?' + qs.stringify(params, { indices: false }),
    method: 'get',
    responseType: 'blob'
  })
}
export default { add, edit, del, init, stockLog, all, exportLog }
